namespace Microsoft.VisualStudio.EnterpriseTools.OperationDesigner
{
    using System;
    using System.Drawing;
    using System.Runtime.InteropServices;

    internal static class NativeMethods
    {
        public const int LB_GETITEMRECT = 0x198;

        [DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true)]
        public static extern bool RedrawWindow(IntPtr hwnd, [In] ref Rectangle rcUpdate, IntPtr hrgnUpdate, RedrawWindowFlags flags);
        [DllImport("user32.dll", CharSet=CharSet.Auto)]
        public static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);
        [DllImport("user32.dll", CharSet=CharSet.Auto)]
        public static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, out Rectangle rect);

        [StructLayout(LayoutKind.Sequential)]
        internal struct Rectangle
        {
            internal int Left;
            internal int Top;
            internal int Right;
            internal int Bottom;
            public Rectangle(int left, int top, int right, int bottom)
            {
                this.Left = left;
                this.Top = top;
                this.Right = right;
                this.Bottom = bottom;
            }

            public Rectangle(System.Drawing.Rectangle rect)
            {
                this.Left = rect.Left;
                this.Top = rect.Top;
                this.Right = rect.Right;
                this.Bottom = rect.Bottom;
            }
        }

        [Flags]
        public enum RedrawWindowFlags
        {
            AllChildren = 0x80,
            Erase = 4,
            EraseNow = 0x200,
            Frame = 0x400,
            InternalPaint = 2,
            Invalidate = 1,
            NoChildren = 0x40,
            NoErase = 0x20,
            NoFrame = 0x800,
            NoInternalPaint = 0x10,
            UpdateNow = 0x100,
            Validate = 8
        }
    }
}

